package de.iritgo.skillfull.component.visitor;

import java.awt.Dimension;

import de.iritgo.skillfull.component.motion.MoveFieldComponent;
import de.iritgo.skillfull.component.motion.PositionComponent;
import de.iritgo.skillfull.component.motion.RotationComponent;
import de.iritgo.skillfull.component.visual.ImageRenderComponent;
import de.iritgo.skillfull.component.visual.ShowPositionCordsComponentImpl;

public class DebugVisitor extends BaseVisitor
{
	private Dimension dimension;
	private int x;
	private int y;
	private float rotation;
	private float scale;
	
	public void visit (ImageRenderComponent renderComponent)
	{
		dimension = renderComponent.getDimension ();
		scale = renderComponent.getScale ();
	}
	
	public void visit (PositionComponent positionComponent)	
	{ 
		if (positionComponent.isRelative ())
		{
			x = x + (int) positionComponent.getX ();
			y = y + (int) positionComponent.getY ();
		}
		else
		{
			x = (int) positionComponent.getX ();
			y = (int) positionComponent.getY ();
		}
	}

	public void visit (MoveFieldComponent moveFieldComponent) 
	{ 
		x = (int) moveFieldComponent.getX ();
		y = (int) moveFieldComponent.getY ();
	}

	public void visit (RotationComponent rotationComponent) 
	{ 
		rotation = rotationComponent.getRotation ();
	}

	public void visit (ShowPositionCordsComponentImpl showPositionCordsComponentImpl) 
	{
//		showPositionCordsComponentImpl.setWidth ((int) dimension.getWidth ());
		showPositionCordsComponentImpl.setHeight ((int) dimension.getHeight ());
		showPositionCordsComponentImpl.setPosInfoX (x);
		showPositionCordsComponentImpl.setPosInfoY (y);
		showPositionCordsComponentImpl.setPosInfoRotation (rotation);
		showPositionCordsComponentImpl.setPosInfoScale (scale);
	}
}
